package cn.fengzhilun.javase.day10.ex;

import java.util.Timer;
import java.util.TimerTask;

import org.junit.Test;

public class DemoTimerTask {
	@Test
	public void test1() throws InterruptedException {
		Timer timer =new Timer();
		
		timer.schedule(new Task1(),0, 2000);
		
		System.out.println("测试程序跑到了这里");
		
		Thread.sleep(10000);
	}
	class Task1 extends TimerTask{

		@Override
		public void run() {
			System.out.println("任务进行中。。。。");
		}
		
		
	}
	
	@Test
	public void test() throws InterruptedException {
		Timer time =new Timer();
		
		time.schedule(new TimerTask() {

			@Override
			public void run() {
				System.out.println("匿名内部类");
			}
			
			
		}, 0,1000);
		
		Thread.sleep(10000);
	}
}

class Task2 extends TimerTask{

	@Override
	public void run() {
		System.out.println("任务进行中");
	}
}